#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 40;
const int mod = 998244353;

int n, K, fac[N], ifac[N];

int upd(int x) { return x + (x >> 31 & mod); }

ll qp(ll x, int t) { ll res = 1; for(; t; t >>= 1, x = x * x % mod) if(t & 1) res = res * x % mod; return res; }
vec operator + (const vec &a, const vec &b) {
	vec c = a; rep(i, 0, K) c[i] = upd(c[i] + b[i] - mod);
	return c;
}
vec operator - (const vec &a, const vec &b) {
	vec c = a; rep(i, 0, K) c[i] = upd(c[i] - b[i]);
	return c;
}
vec operator * (const vec &a, const vec &b) {
	vec c(K + 1, 0); rep(i, 0, K) rep(j, 0, K - i) c[i + j] = upd(c[i + j] + 1ll * a[i] * b[j] % mod - mod);
	return c;
}
vec operator - (const vec &a) { vec c(K + 1, 0); return c - a; }

vec exp(int t) {
	vec c(K + 1, 0); int fc = 1;
	rep(i, 0, K) {
		c[i] = 1ll * fc * ifac[i] % mod; fc = 1ll * fc * t % mod;
	} return c;
}
void out(vec a) { rep(i, 0, K) cerr << a[i] << " "; cerr << endl; }

vec operator / (const vec &a, const vec &b) {
	vec c = a;
	rep(i, 0, K) {
		rep(j, 1, i) c[i] = upd(c[i] - 1ll * b[j] * c[i - j] % mod);
		c[i] = c[i] * qp(b[0], mod - 2) % mod;
	} //out(b); out(c); out(b * c); out(a); assert(b * c == a);
	return c;
}

vec mat[N][N];

ll Gauss() {
	vec res(K + 1, 0); res[0] = 1;
	rep(i, 1, n - 1) {
		int k = n; rep(j, i, n - 1) if(mat[j][i][0]) { k = i; break; }
		if(k == n) return 0; if(k ^ i) swap(mat[k], mat[i]), res = -res;
		rep(j, i + 1, n - 1) {
			vec t = mat[j][i] / mat[i][i];
			rep(k, i, n - 1) mat[j][k] = mat[j][k] - mat[i][k] * t;
		}
	}
	rep(i, 1, n - 1) res = res * mat[i][i];
	return 1ll * res[K] * fac[K] % mod;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	n = in, K = in;
	fac[0] = 1; rep(i, 1, K) fac[i] = 1ll * fac[i - 1] * i % mod;
	ifac[K] = qp(fac[K], mod - 2); per(i, K - 1, 0) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % mod;
	rep(i, 1, n) rep(j, 1, n) mat[i][j].resize(K + 1);
	rep(i, 1, n) rep(j, 1, n) {
		int w = in; vec t = exp(w);
		mat[i][i] = mat[i][i] + t; mat[i][j] = mat[i][j] - t;
	}
	printf("%lld\n", Gauss());
	return 0;
}
